//
//  ProfieDetailViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/3.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "ProfieDetailViewController.h"
#import "ProDetailCell.h"
@interface ProfieDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataSouce;
@property(nonatomic,strong)NSString *total_Money;
@end

@implementation ProfieDetailViewController


- (void)viewDidLoad {
    [super viewDidLoad];
   // self.view.backgroundColor = [UIColor redColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
       self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = 0;
    self.tableView.backgroundColor  = [UIColor clearColor];

    [self loadList];
    // Do any additional setup after loading the view from its nib.
}



-(void)loadList
{
    NSDictionary *param = @{@"ac":@"member",
                            @"op":@"member",
                            @"ctrl":@"live_anchor",
                            @"ta":@"actmoney"};
    [self weqPostHandle:param success:^(id response) {
        [self.tableView.mj_header endRefreshing];
        if(response){
            self.total_Money = [NSString stringWithFormat:@"%@",response[@"data"][@"month_total_money"]];
            [self.dataSouce addObjectsFromArray:response[@"data"][@"list"]];
            [self.tableView reloadData];
        }
    } failure:^(NSError *error) {
        [self.tableView.mj_header endRefreshing];
    }];
}



-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 100;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 240;
}


-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screen_width, 100)];
   // view.backgroundColor = [UIColor redColor];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 10, screen_width, 20)];
    label.text = @"本月获得佣金";
    label.font = [UIFont systemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    UILabel *nums = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, screen_width, 40)];
    nums.text = self.total_Money;
     nums.textAlignment = NSTextAlignmentCenter;
    nums.font = [UIFont fontWithName:@"Helvetica-Bold" size:22];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 70, screen_width, 30);
    [btn setTitle:@"查看全部" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn addTarget:self action:@selector(checkAll) forControlEvents:UIControlEventTouchUpInside];
   // btn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Thin" size:14];
    
    [view addSubview:label];
    [view addSubview:nums];
    [view addSubview:btn];
    return view;
}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSouce.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellId = @"cell";
    ProDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(!cell){
        cell = [[[NSBundle mainBundle]loadNibNamed:@"ProDetailCell" owner:self options:nil]lastObject];
    }
    [cell bindData:self.dataSouce[indexPath.row]];
    return cell;
}


-(void)checkAll{
    
}


#pragma mark - getter&&setter
-(NSMutableArray *)dataSouce
{
    if(!_dataSouce){
        _dataSouce = [NSMutableArray array];
    }
    return _dataSouce;
}

@end
